import requests

headers = {
    'accept': 'application/json',
    'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
    'cache-control': 'no-cache',
    'origin': 'https://www.autohome.com.cn',
    'pragma': 'no-cache',
    'priority': 'u=1, i',
    'referer': 'https://www.autohome.com.cn/',
    'sec-ch-ua': '"Chromium";v="136", "Microsoft Edge";v="136", "Not.A/Brand";v="99"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'sec-fetch-dest': 'empty',
    'sec-fetch-mode': 'cors',
    'sec-fetch-site': 'same-site',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36 Edg/136.0.0.0',
}

params = {
    'from': '28',
    'pm': '2',
    'pluginversion': '11.65.0',
    'model': '1',
    'channel': '0',
    'pageindex': '1',
    'pagesize': '50',
    'typeid': '1',
    'subranktypeid': '1',
    'levelid': '1,2,3,4,5,6',
    'price': '0-9000',
    'date': '2025-04',
}

response = requests.get('https://car-web-api.autohome.com.cn/car/rank/getList', params=params, headers=headers).json()
char_lists =response['result']['list']
for char_list in char_lists:
    Rank = char_list['rank']
    # # 价格]
    Price = char_list['priceinfo']
    # # 销量
    Sales = char_list['salecount']
    # # 评分
    Divide = char_list['scorevalue']
    # # 车名
    Car_name = char_list['seriesname']
    # 车id
    Car_id = char_list['seriesid']
    # # 图片
    Car_img = char_list['seriesimage']
    print(f"排名：{Rank}，车名：{Car_name}，评分：{Divide}，价格：{Price},销量：{Sales}，图片：{Car_img}，url：https://www.autohome.com.cn/{Car_id}/#pvareaid=6861512")
    print(char_list)